package com.ctrip.corp.obt.shard.infrastructure.etcd;

import com.ctrip.corp.obt.generic.utils.EnvironmentHolder;
import com.ctrip.corp.obt.platform.config.shardsource.AbstractShardSourceConfigurator;
import com.ctrip.corp.obt.platform.config.shardsource.ShardSourceConfig;
import com.ctrip.corp.obt.shard.loader.IShardSourceLoader;
import lombok.RequiredArgsConstructor;

/**
 * @author marco.zheng   (cq_zheng@trip.com)
 * @date 2023/6/30
 */
@RequiredArgsConstructor
public class ShardSourceConfigurator extends AbstractShardSourceConfigurator {

    private final IShardSourceLoader shardSourceLoader;

    @Override
    protected void handleDelete(String key) {

    }

    @Override
    protected void handlePut(String key, ShardSourceConfig shardSourceConfig) {
        // String property = EnvironmentHolder.getProperty("spring.application.name");
        shardSourceLoader.refresh(shardSourceConfig.getTenantId());
    }
}
